--
-- Author: shunguo.chen
-- Date: 2018-03-19 14:52:00
--
-- ChessSelectEventRender 谜棋事件选择render
--

local ClassRef = app.mvc.createRenderClass(...)

function ClassRef.createWithData(data, node)
    local sprite = ClassRef.extend(node)
    if node == nil then
        ccui.Helper:doLayout(sprite)
    end
    sprite:init(data)
    return sprite
end
function ClassRef.create(node)
    return ClassRef.createWithData(nil, node)
end

--data = {beSelected=true/false, selectID=, data=ChessAction}
function ClassRef:init(data)
    self.super.init(self, data)

    display.uiAddClick(self, function()
            executeFunc(self._onClick, self)
        end, true, 0.05)
    self:refresh()
end

function ClassRef:refresh()
    if self._data then
        local action = self._data.data
        self._ui.tlt:setString(action:getName())
        self._ui.icon:loadTexture(action:getIcon())
        self._ui.tips:setString(action:getMessage())
    end
end

function ClassRef:onBtnClick(cb)
    self._onClick = cb
end

return ClassRef
